package cn.sunny360.core.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class ParamUtils {
public  final  static  String USER_TOEKN="userToken";

    public static Map<String, String> analysis(String url) {
        Map<String, String> paramMap = new HashMap<String, String>(2);
        if (StringUtils.isNotEmpty(url)) {// 如果URL不是空字符串
            url = url.substring(url.indexOf('?') + 1);

            String paramaters[] = url.split("&");
            for (String param : paramaters) {
                String values[] = param.split("=");
                if(values.length>1) {
                    paramMap.put(values[0], values[1]);
                }
            }
        }
        return  paramMap;
    }



    public static void main(String[] args) {
        String test = "token=";
        Map<String, String> analysis = analysis(test);
        System.out.println("token = " + analysis.get("token"));
        System.out.println("id = " + analysis.get("id"));
    }
}
